package com.keguoyu.easymvp.commons;

import java.util.Set;

import com.keguoyu.easymvp.commons.supplier.SupplierContainer;

public abstract class ValueTaker {

  public abstract <T> T take(SupplierContainer obj, String fieldName);

  public abstract <T> T take(SupplierContainer obj, Class<T> tClass);

  public abstract <T> void set(SupplierContainer obj, String fieldName, T value);

  public abstract <T> void set(SupplierContainer obj, Class tClass, T value);

  public abstract Set<String> allFieldNames(SupplierContainer obj);

  public abstract Set<Class> allTypes(SupplierContainer obj);

  public final boolean have(SupplierContainer obj, String fieldName) {
    Set<String> names = allFieldNames(obj);
    return names != null && names.contains(fieldName);
  }

  public final boolean have(SupplierContainer obj, Class tClass) {
    Set<Class> types = allTypes(obj);
    return types != null && types.contains(tClass);
  }

  public abstract Set<Object> allDirectFields(SupplierContainer obj);

}
